
import React from 'react'
import { BrowserRouter as Router, Route, Redirect } from 'react-router-dom'

import Home from './pages/Home'
import CityList from './pages/CityList'
import Map from './pages/Map'
// 房源详情组件
import Details from './pages/Details'
import Login from './pages/Login'

import Favor from './pages/Favor'

// 发布房源列表
import Rent from './pages/Rent'
import AddRent from './pages/Rent/AddRent'
import Search from './pages/Rent/Search'

// 导入路由导航
import AuthRoute from './components/AuthRoute'

function App() {
  return (
    <Router>
      <div className="App">
        {/* 路由入口 */}
        {/* <Link to='/home'>首页</Link>
        <Link to='/citylist'>城市列表</Link> */}


        {/* 默认路由，跳转到/home实现路由的重定向到首页 */}
        <Route path="/" exact render={() => <Redirect to="/home"></Redirect>}></Route>
        {/* 路由出口 */}
        <Route path="/home" component={Home}></Route>
        <Route path="/citylist" component={CityList}></Route>
        {/* <Route path="/map" component={Map}></Route> */}
        <AuthRoute path="/map" component={Map}></AuthRoute>

        {/* 房源详情路由信息 */}
        <Route path="/detail/:id" component={Details}></Route>

        {/* 登录路由 */}
        <Route path="/login" component={Login}></Route>

        {/* 收藏列表路由 */}
        <AuthRoute path="/favor" component={Favor}></AuthRoute>

        {/* 发布房源列表路由 */}
        <AuthRoute path="/rent" exact component={Rent}></AuthRoute>
        <Route path="/rent/search" component={Search}></Route>
        <AuthRoute path="/rent/addRent" component={AddRent}></AuthRoute>

        {/* 注册路由，待实现 */}
        {/* <Route path="/register" component={Register}></Route> */}
      </div>
    </Router>
  );
}

export default App;
